package ahp.client.layouts;


import java.util.ArrayList;

import ahp.client.AHP;
import ahp.client.Osoba;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ClickEvent;

public class KandydatkiLayout extends Composite {
	
	
	FlowPanel mainPanel=new FlowPanel();
	private Image image;
	public ArrayList<Osoba>selected=new ArrayList<Osoba>();
	
	
	public KandydatkiLayout(ArrayList<Osoba>kandydatki) {
		
		initWidget(mainPanel);
		mainPanel.addStyleName("kandydatki-content");
		
		for (final Osoba os : kandydatki) {
			FlowPanel flowPanel= new FlowPanel();
			final Image image = new Image(os.picture_url);
			Label lab = new Label(os.imie);
			flowPanel.add(image);
			flowPanel.add(lab);
			image.setStyleName("");
			
			image.addClickHandler(new ClickHandler() {
				int count=0;
				public void onClick(ClickEvent event) {
					if((count%2)==0){
						selected.add(os);
						image.addStyleName("selected");				
//						System.out.println(selected.size());
					}
					else{
						selected.remove(os);
						image.removeStyleName("selected");	
//						System.out.println(selected.size());
					}
					count++;

				}
			});
			lab.setStyleName("name");	
			mainPanel.add(flowPanel);
			flowPanel.setStyleName("kandydatki-item");
		}	
		
	}

		

}
